/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 17655
 * Date: 2025-06-30
 * Time: 19:13
 */
public class test3 {
    public int maxSubArray(int[] nums) {
        int n = nums.length;
        // 代表fi
        int pre = 0;
        int ret = nums[0];
        for(int num:nums){
            // 判断的是num这里
            pre = Math.max(num,pre+num);
            // 更新最大值
            ret = Math.max(pre,ret);
        }
        return ret;
    }
}
